@using CodeBuilder
@using CodeBuilder.Models.TemplateModels
@inherits RazorEngine.Templating.TemplateBase<CodeBuilder.Models.TemplateModels.DtoFileModel>

<template>
    <crud :entity-name="entityName"
          :dialog-enity.sync="entity"
          :request-param="pagerequest"
          :keyword-placeholder="keywordPlaceholder"
          :dialog-optins="dialogOptins"
          @@dialogFormClearValidate="handleFormClearValidate"
          @@dialogFormValidate="handleFormValidate">
        <template slot="FilterItems" />

        <template slot="TableColumns">

            @foreach (ClassProperty classProperty in Model.ClassPropertys)
            {
                if (classProperty.Name == "TenantId")
                {
                    continue;
                }

                <el-table-column prop="@classProperty.Name.FirstCharToLower()"
                                 sortable="custom"
                                 :label="L('@classProperty.Name')"/>
            }
        </template>

        <createOrUpdateCommonTask ref="CreateOrEditDialog"
                                  slot="CreateOrEditDialog"
                                  :entity="entity" />
    </crud>
</template>
<script>
import crud from '@@/components/CrudCodeBuild'
import createOrUpdateCommonTask from './components/CreateOrUpdate@(Model.Name)'
export default {
  name: '@(Model.Name)',
  components: { crud, createOrUpdateCommonTask },
  data() {
    return {
      entity: {},
      entityName: '@(Model.Name.FirstCharToLower())',
      pagerequest: null,
      keywordPlaceholder: this.L('@(Model.Name)') + '/' + this.L('Name'),
      dialogOptins: {
        width: '700px',
        createEnityParam: { permissions: [] },
        createTitle: this.L('Create'),
        editTitle: this.L('Edit'),
        deleteConfirm: this.L('Delete')
      }
    }
  },
  methods: {
    handleFormClearValidate() {
      this.$refs.CreateOrEditDialog.clearValidate()
    },
    handleFormValidate(cb) {
      this.$refs.CreateOrEditDialog.validate(cb)
    }
  }

}

</script>
